<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>22_基本数据类型-高级-string-String方法来转换其他数据类型</title>
    </head>
    <body>
        <script>
            // 接下来的操作是将后端传递给你的数据转换为字符串类型的操作


            // string
            var str = '123';
            // 判断str的数据类型 思密达
            console.log(typeof str);

            var strToString = String(str);
            console.log(typeof strToString);
            console.log(strToString);


            // number
            var num = 718;
            console.log(typeof num);

            var numToString = String(num);
            console.log(typeof numToString);
            console.log(numToString);


            // boolean
            var bool = true;
            console.log(typeof bool);

            var boolToString = String(bool);
            console.log(typeof boolToString);
            console.log(boolToString);


            // undefined
            var un = undefined;
            console.log(typeof un);

            var unToString = String(un);
            console.log(typeof unToString);
            console.log(unToString);

            // null
            // null判断数据类型的时候  会展示的是object
            var n = null; 
            console.log(typeof n);

            var nToString = String(n);
            console.log(typeof nToString);
            console.log(nToString);
        </script>
    </body>
</html>